package example13_2;

import java.net.InetAddress;

public class Example13_2 {
    public static void main(String[] args) {
        try
		{
			//获取表示名称为wyf的主机对应IP地址的InetAddress对象
			InetAddress ip=InetAddress.getByName("www.tup.tsinghua.edu.cn");
			//打印InetAddress对象描述的IP地址
			System.out.println("InetAddress对应的IP地址为："+ip.getHostAddress()+"，");
			//打印InetAddress对象描述的主机名
			System.out.println("主机名为："+ip.getHostName()+"。");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
    }
}
